{% extends "base/front.html" %}

{% block title %}Interest Blog Home | SaintIC{% endblock %}

{% block content %}

<article class="post">

  <header class="post-header">
    <p>
        <a href="{{ url_for('front.profile', change='avatar') }}" title="Change Your Avatar"><img src="{{ user.get('avatar') or url_for('static', filename='img/avatar/default.jpg') }}" class="circular--square home-avatar"></a>
    </p>
  </header>

  <div class="post-content">

    {% if user.get("cname") %}
        <p>
            <attr title="{{ user.get('motto') or '' }}">{{ user.get('cname') }}</attr>
        </p>
    {% endif %}

    {% if user.get('gender') == '男' %}
        <p>A handsome boy Joined on {{ user.get('time') }}</p>
    {% elif user.get('gender') == '女' %}
        <p>A pretty girl Joined on {{ user.get('time') }}</p>
    {% else %}
        <p>Joined on {{ user.get('time') }}</p>
    {% endif %}

    {% if user.get('url') %}
        <p>我的网址: <a href="{% if 'http' in user.get('url') %}{{ user.get('url') }}{% else %}{{ 'http://' + user.get('url') }}{% endif %}" target="_blank">{{ user.get('url') }}</a></p>
    {% endif %}

    {% if user.get('email') %}
        <p>我的邮箱: <a href="mailto:{{ user.get('email') }}">{{ user.get('email') }}</a></p>
    {% endif %}

    {% if user.get('weibo') %}
        <p>我的微博: <a href="{% if 'http' in user.get('weibo') %}{{ user.get('weibo') }}{% else %}{{ 'http://' + user.get('weibo') }}{% endif %}" target="_blank">{{ user.get('weibo') }}</a></p>
    {% endif %}

    {% if user.get('github') %}
        <p>我的代码: <a href="{% if 'http' in user.get('github') %}{{ user.get('github') }}{% else %}{{ 'http://' + user.get('github') }}{% endif %}" target="_blank">{{ user.get('github') }}</a>
        </p>
    {% endif %}

    <p><a href="{{ url_for('front.profile', change='password') }}" title="Change Your Password">修改密码</a>&nbsp;</p>

    <p><a href="{{ url_for('front.profile', change='profile') }}" title="Change Your Profile">修改个人资料</a>&nbsp;</p>

    {% if blog %}
    <div>
        <h1 class="page-heading">文章展<span class="badge green">{{ blog|length }}</span></h1>
        <ul class="post-list">
        {% for _ in blog %}
          <li>
            <scan>
            <a href="{{ url_for('front.blogShow', bid=_.get('id')) }}">{{ _.get("title") }}</a>
            <sub>{{ _.get("create_time") }}</sub> |
            <sub>{{ _.get("sources") }}</sub> |
            <sub>{{ _.get("catalog") }}</sub> |
            <sub>{{ _.get("tag") }}</sub>
            </scan>
          </li>
        {% endfor %}
        </ul>
    </div>
    {% endif %}

    {% if g.plugins["ShowGitHub"] in ("true", "True", True) and user.get('github') %}
    <div>
        <h1 class="page-heading">代码库<span class="badge green" id="repo_count"></span></h1>
        <ul class="post-list" id="repo_list"></ul>
    </div>
    {% endif %}
  </div>

</article>

{% endblock %}

{% block script %}
{% if g.plugins['Weather'] %}
<!-- 实时天气查询插件 -->
<script>(function(T,h,i,n,k,P,a,g,e){g=function(){P=h.createElement(i);a=h.getElementsByTagName(i)[0];P.src=k;P.charset="utf-8";P.async=1;a.parentNode.insertBefore(P,a)};T["ThinkPageWeatherWidgetObject"]=n;T[n]||(T[n]=function(){(T[n].q=T[n].q||[]).push(arguments)});T[n].l=+new Date();if(T.attachEvent){T.attachEvent("onload",g)}else{T.addEventListener("load",g,false)}}(window,document,"script","tpwidget","//widget.thinkpage.cn/widget/chameleon.js"))</script>
<script>tpwidget("init", {
    "flavor": "bubble",
    "location": "WX4FBXXFKE4F",
    "geolocation": "enabled",
    "position": "top-left",
    "margin": "10px 10px",
    "language": "zh-chs",
    "unit": "c",
    "theme": "chameleon",
    "uid": "U617F38FE8",
    "hash": "36131d08119a61b3d88add1b6316a395"
});
tpwidget("show");
</script>
{% endif %}

{% if g.plugins["ShowGitHub"] in ("true", "True", True) and user.get('github') %}
<script type="text/javascript">
init = {
    getRepos: function() {
        var GitHubUser = "{{ user.get('github') }}".split("/");
        GitHubUser = GitHubUser[GitHubUser.length-1];
        console.log(GitHubUser);
        $.ajax({
            type: "GET",
            url: "https://api.github.com/users/" + GitHubUser + "/repos?per_page=49",
            dataType: "json",
            success: function(result) {
                for( i in result ) {
                   msg = "<li><b><a href='" + result[i].html_url + "' title='" + result[i].description + "' target='_blank'>" + result[i].full_name + "</a></b><span class='badge red'>" + result[i].watchers_count + "," + result[i].stargazers_count + "," + result[i].forks_count + "</span>&nbsp;</li>";
                    $("#repo_list").append(msg);
                }
                $("#repo_count").append(result.length);
            },
            error: function(result) {
                console.log(result);
                alert("GitHub代码库获取错误，请刷新重试！");
            }
        });
    },
};

$(document).ready(function() {
    init.getRepos();
});
</script>
{% endif %}

{% endblock %}
